Skip to content

feat:add --dryrun#1422

Merged
genedna merged 12 commits into
gitmono-dev:mainfrom
mengnankkkk:feat-mengnankk
Sep 8, 2025
Merged

feat:add --dryrun#1422
genedna merged 12 commits into
gitmono-dev:mainfrom
mengnankkkk:feat-mengnankk

Conversation

@mengnankkkk

@mengnankkkk mengnankkkk commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

from #1421

@vercel

vercel Bot commented Sep 8, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
mega Ready Ready Preview Comment Sep 8, 2025 2:10pm

@mengnankkkk mengnankkkk changed the title feat(remove):add --dryrun feat:add --dryrun Sep 8, 2025
@genedna
genedna requested a review from Copilot September 8, 2025 08:25

This comment was marked as outdated.

@genedna genedna left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: zhou yong kang <mengnankkzhou@gmail.com>

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: zhou yong kang <mengnankkzhou@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a --dry-run flag for the libra rm command that shows what files would be removed without actually performing the removal operation. This allows users to preview the effects of their remove command before executing it.

  • Adds dry_run field to RemoveArgs struct with appropriate CLI argument configuration
  • Implements dry-run logic that displays what would be removed while preserving files and index state
  • Adds comprehensive test coverage for various dry-run scenarios including basic removal, cached removal, and recursive directory removal

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
libra/src/command/remove.rs Adds dry_run field to RemoveArgs and implements the core dry-run functionality
libra/tests/command/remove_test.rs Updates existing tests to include dry_run field and adds three new test functions for dry-run scenarios
libra/examples/test_dry_run.rs Provides a standalone example demonstrating the dry-run functionality
aria/contents/docs/libra/command/rm/index.mdx Documents the new --dry-run option with usage examples

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +82 to +87
if index.tracked(&path_wd, 0) {
println!("rm '{}'", path_wd.bright_yellow());
} else {
// Even untracked files are processed in force mode
println!("rm '{}'", path_wd.bright_yellow());
}

Copilot AI Sep 8, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The force mode logic has duplicate println! statements that could be simplified. Consider consolidating the output since both tracked and untracked files produce the same message.

Suggested change
if index.tracked(&path_wd, 0) {
println!("rm '{}'", path_wd.bright_yellow());
} else {
// Even untracked files are processed in force mode
println!("rm '{}'", path_wd.bright_yellow());
}
// In force mode, print removal message regardless of tracked status
println!("rm '{}'", path_wd.bright_yellow());

Copilot uses AI. Check for mistakes.
pathspec: vec![file1_path.to_string_lossy().to_string(), file2_path.to_string_lossy().to_string()],
cached: false,
recursive: false,
force: true, // Use force mode to avoid requiring git repository

Copilot AI Sep 8, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example won't work correctly because the execute function checks for repository existence at the beginning and returns early if no repository is found, making the force flag ineffective for this purpose.

Copilot uses AI. Check for mistakes.
@genedna
genedna merged commit 6f702f8 into gitmono-dev:main Sep 8, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants